/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author selam
 */
@Entity
@Table(name = "excursion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Excursion.findAll", query = "SELECT e FROM Excursion e"),
    @NamedQuery(name = "Excursion.findByExcursionId", query = "SELECT e FROM Excursion e WHERE e.excursionId = :excursionId"),
    @NamedQuery(name = "Excursion.findByRoute", query = "SELECT e FROM Excursion e WHERE e.route = :route"),
    @NamedQuery(name = "Excursion.findByDate", query = "SELECT e FROM Excursion e WHERE e.date = :date"),
    @NamedQuery(name = "Excursion.findByPrice", query = "SELECT e FROM Excursion e WHERE e.price = :price")})
public class Excursion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ExcursionId")
    private Integer excursionId;
    @Size(max = 45)
    @Column(name = "Route")
    private String route;
    @Column(name = "Date")
    @Temporal(TemporalType.DATE)
    private Date date;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Price")
    private Float price;
    @JoinColumn(name = "ExcursionId", referencedColumnName = "ProductId", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Product product;

    public Excursion() {
    }

    public Excursion(Integer excursionId) {
        this.excursionId = excursionId;
    }

    public Integer getExcursionId() {
        return excursionId;
    }

    public void setExcursionId(Integer excursionId) {
        this.excursionId = excursionId;
    }

    public String getRoute() {
        return route;
    }

    public void setRoute(String route) {
        this.route = route;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Float getPrice() {
        return price;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (excursionId != null ? excursionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Excursion)) {
            return false;
        }
        Excursion other = (Excursion) object;
        if ((this.excursionId == null && other.excursionId != null) || (this.excursionId != null && !this.excursionId.equals(other.excursionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Excursion[ excursionId=" + excursionId + " ]";
    }
    
}
